<?php

if (!defined('ZZQSS')){

        die("Access Denied");

}

class GoodsForecastClass {

        var $db;

        var $table_order;

        var $tablepre;

        function __construct(){

                //设置全局变量

                global $db,$tablepre;

                $this->db=$db;

                $this->tablepre=$tablepre;

                $this->table_order=new TableClass("goodsforecast","gid");

        }

        function OrderClass(){

                $this->__construct();

        }

        //对象获取

        function &init() {

                static $object;

                if(empty($object)) {

                        $object = new GoodsForecastClass();

                }

                return $object;

        }



        //添加

        function add($dataarray){

                return $this->table_order->add($dataarray);

        }

        //编辑

        function edit($eid,$dataarray){

                return $this->table_order->edit($eid,$dataarray);

        }

        //统计

        function getcount($where=""){

                return $this->table_order->getcount($where);

        }

        function getuserdata($limit="",$where="",$orderby="",$field="*",$type='ALL'){



                $tempdata=array();

                if(!empty($limit))$limit=" limit $limit ";

                if(!empty($where))$where=" where $where ";

                if(!empty($orderby))$orderby=" order by $orderby ";else $orderby=" order by ".$this->table_order->idname." desc";

                if($type=="ALL")$addsql=" AS O left join {$this->tablepre}users AS U ON O.uname=U.uname ";

                $sql="select {$field} from {$this->table_order->table}{$addsql}{$where}{$orderby}{$limit}";

                $query =$this->db->query($sql);
                while($value = $this->db->fetch_array($query)) {

                        $tempdata[]=$value;

                }

                return $tempdata;

        }
		
		function getuserdatacount($where=""){
            if(!empty($where))$where=" where $where ";
            $sql="select count(1) from {$this->table_order->table} as O {$where}";
			$count= $this->db->result_first($sql);
			return $count;
		}

        //获取一个

        function getone($gid,$field="*"){

                return $this->table_order->getone($gid,$field);

        }
		//检测快递信息是否存在
        function checkEx($extype, $ex){
        	return $this->table_order->getdata('', 'extype = \''.$extype.'\' AND ex = \''.$ex.'\'');
        }
        //根据标识删除

        function giddel($gid){

                return $this->table_order->del($gid);

        }

        /**

         * 获取状态内容

         * @param int $index

         * @author iceinto<iceinto@163.com>

         */

        function getStatusInfo($index){

                //1未入库2已入库3已经核算4已经支付5已经发货6已经收货7已经评论

                $statusInfo = array();

                $statusInfo['1'] = '未入库';

                $statusInfo['2'] = '已经入库';

                $statusInfo['3'] = '已入库';

                $statusInfo['4'] = '已出库';

                $statusInfo['5'] = '已经出库';

                return $statusInfo[$index];

        }

        //编辑

        function editStatus($eid,$status){

                $dataarray['status'] = $status;

                return $this->table_order->edit($eid,$dataarray);

        }

}

?>